package zuoye5;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;


/*斗地主排序
你把准备好的牌放到hashmap
Hashmap<Integer,String> map;
0-大王 1-小王 
2-红桃2 			3-梅花2 		4-方块2 			5-黑桃2
6-红桃A...
你给玩家发牌 key 
124659865
排序：
对key排序
看牌：通过map里面去取key*/
public class ZuoYe8 {

	public static void main(String[] args) {
		        //准备牌
				ArrayList<Integer> poker=new ArrayList<Integer>();
				//定义两个数组
				String[] colors={"♥","♣","♦","♠"}; 
				String[] numbers={"2","A","K","Q","J","10","9","8","7","6","5","4","3"};
				
				//组装52张牌
				HashMap<Integer,String> map = new HashMap<>();
				map.put(0, "大王");
				map.put(1, "小王");
				int Key = 1;
				poker.add(0);
				poker.add(1);
				for(String number:numbers){
					for(String color:colors){
						Key++;
						poker.add(Key);
						map.put(Key,color+number);
					}
				}
				
				
				
				//洗牌
				Collections.shuffle(poker);
				
				Player playe1=new Player("老王");
				Player playe2=new Player("老李");
				Player playe3=new Player("老刘");
				//摸牌
				for(int i=0;i<poker.size();i++){
					//每一张牌
					Integer p = poker.get(i);
					if(i<=51){
						if(i%3==0){
							playe1.getList().add(p);
						}else if(i%3==1){
							playe2.getList().add(p);
						}else{
							playe3.getList().add(p);
						}
					}
				}
				Collections.sort(playe1.getList());
				Collections.sort(playe2.getList());
				Collections.sort(playe3.getList());
				//看牌
				System.out.println(playe1.getName());				
				for(int i : playe1.getList()){
					System.out.printf(map.get(i)+",");
				}
				System.out.println(" ");
                System.out.println(playe2.getName());
				for(int i : playe2.getList()){
					System.out.printf(map.get(i)+",");
				}
				System.out.println(" ");
				System.out.println(playe3.getName());
				for(int i : playe3.getList()){
					System.out.printf(map.get(i)+",");
				}
				
				
	}
}
